<template>
  <div class="search" id="searchReset">
    <h2>资源检索</h2>
    <div class="search-form">
      <el-input
        placeholder="请输入检索关键字..."
        v-model="keyword"
        class="input-with-select"
      >
        <el-select v-model="select" slot="prepend" placeholder="请选择">
          <el-option
            v-for="v in searchLeftFileData"
            :key="v.value"
            :label="v.label"
            :value="v.value"
          ></el-option>
        </el-select>
        <el-button
          slot="append"
          icon="el-icon-search"
          @click="toSearch()"
        ></el-button>
      </el-input>
      <!-- <span class="el-icon-search ipt-btn"></span>
      -->
      <button class="search-button" @click="toSearch()">高级检索</button>
    </div>
    <div class="checkbox-wrap">
      <el-checkbox
        :indeterminate="isIndeterminate"
        v-model="checkAll"
        @change="handleCheckAllChange"
        class="check-all"
        >全部</el-checkbox
      >
      <el-checkbox-group
        v-model="checkedCities"
        @change="handleCheckedCitiesChange"
        class="check-item"
      >
        <el-checkbox v-for="city in cities" :label="city.id" :key="city.id">{{
          city.name
        }}</el-checkbox>
      </el-checkbox-group>
    </div>
  </div>
</template>
<script>
import homeConfig from '@/mixins/homeConfig'
export default {
  mixins: [homeConfig],
  data() {
    return {
      checkAll: false,
      checkedCities: [],
      isIndeterminate: false,
      keyword: '',
      select: '0',
      cities: [],
    }
  },
  mounted() {
    this.cities = this.searchLibraryList
  },
  methods: {
    handleCheckAllChange(val) {
      this.checkedCities = val ? JSON.parse(JSON.stringify(this.cities)) : []
      this.isIndeterminate = false
    },
    handleCheckedCitiesChange(value) {
      let checkedCount = value.length
      this.checkAll = checkedCount === this.cities.length
      this.isIndeterminate =
        checkedCount > 0 && checkedCount < this.cities.length
    },
    toSearch() {
      let type = this.checkedCities.join()
      this.$router.push({
        path: '../advancedSearch',
        query: {
          type: 9,
          keyword: this.keyword,
          searchType: type,
          textType: this.select,
        },
      })
    },
  },
}
</script>
<style scoped lang="scss">
.search {
  width: 100%;
  height: 100%;
  h2 {
    font-size: 24px;
    text-align: center;
    line-height: 4em;
    color: #fff;
  }
  .search-form {
    position: relative;
    margin: 0 auto;
    width: 1300px;
    padding: 0 50px;

    // text-align: center;
  }
  .search-button {
    float: right;
    width: 160px;
    height: 50px;
    border-radius: 50px;
    outline: none;
    border: 0 none;
    color: #000;
    font-size: 18px;
    cursor: pointer;
    background: #f5f7fa;
    transition: all 0.2s;
    &:hover {
      transform: translateY(-3px);
    }
  }
  .ipt-txt {
    width: 1130px;
    height: 50px;
    outline: none;
    border-radius: 80px;
    text-indent: 2em;
    font-size: 16px;
    color: #333;
    border: 0 none;
  }
  .ipt-btn {
    position: absolute;
    right: 230px;
    top: 14px;
    font-size: 26px;
    color: var(--colorH1);
    cursor: pointer;
    font-weight: bold;
  }
}
.checkbox-wrap {
  // width: 1400px;
  padding-top: 30px;
  margin: 0 auto;
  .check-all {
    float: left;
    margin-right: 26px;
    margin-left: 62px;
  }
  .check-item {
    float: left;
  }
}
@media screen and (max-width: 1400px) {
  .search .search-form {
    width: 90%;
  }
  #searchReset .el-input-group {
    width: 84%;
  }
}
</style>
<style >
#searchReset .el-input__inner {
  height: 50px;
  line-height: 50px;

  color: #6a6363;
}
#searchReset .el-input-group__prepend {
  border-radius: 30px 0 0 30px;
}
#searchReset button.el-button.el-button--default {
  font-size: 26px;
  color: #000;
  font-weight: 900;
}
#searchReset .el-input-group__append {
  background: #f6c131;
  border-radius: 0 30px 30px 0;
}
#searchReset .el-select .el-input {
  width: 105px;
  text-align: center;
}
#searchReset .el-select .el-input input {
  text-align: center;
}
#searchReset .el-input.is-active .el-input__inner,
#searchReset .el-input__inner:focus {
  border-color: transparent !important;
}
#searchReset .el-input-group {
  width: 87%;
}
</style>
